import 'dart:convert' show json;

T asT<T>(dynamic value) {
  if (value is T) {
    return value;
  }

  return null;
}

class StaffInfo {
  StaffInfo({
    this.id,
    this.service_centre,
    this.real_name,
    this.department,
    this.role,
    this.add_time,
    this.customer_num,
  });

  factory StaffInfo.fromJson(Map<String, dynamic> jsonRes) => jsonRes == null
      ? null
      : StaffInfo(
    id: asT<int>(jsonRes['id']),
    service_centre: asT<String>(jsonRes['service_centre']),
    real_name: asT<String>(jsonRes['real_name']),
    department: asT<String>(jsonRes['department']),
    role: asT<String>(jsonRes['role']),
    add_time: asT<String>(jsonRes['add_time']),
    customer_num: asT<int>(jsonRes['customer_num']),
  );

  int id;
  String service_centre;
  String real_name;
  String department;
  String role;
  String add_time;
  int customer_num;

  Map<String, dynamic> toJson() => <String, dynamic>{
    'id': id,
    'service_centre': service_centre,
    'real_name': real_name,
    'department': department,
    'role': role,
    'add_time': add_time,
    'customer_num': customer_num,
  };
  @override
  String toString() {
    return json.encode(this);
  }
}
